new functions, recursive process tree to specified depth
authorLars Hamann <lars@src.gnome.org>
Mon, 20 Jul 1998 19:45:45 +0000 (19:45 +0000)
committerLars Hamann <lars@src.gnome.org>
Mon, 20 Jul 1998 19:45:45 +0000 (19:45 +0000)
* gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
  (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
  tree to specified depth
  (gtk_ctree_expand_to_depth): expand tree to specified depth
  (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkctree.c
gtk/gtkctree.h

index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 0d8b57edbc2edb1c2c752b5ef91a44da925dcab2..5613f285c2678a73d50bac26b957b351a19c9f44 100644 (file)
@@ -1,3 +1,11 @@
+Mon Jul 20 21:28:18 1998  Lars Hamann  <lars@gtk.org>
+
+       * gtk/gtkctree.c (gtk_ctree_post_recursive_to_depth)
+       (gtk_ctree_pre_recursive_to_depth): new functions, recursive process
+       tree to specified depth
+       (gtk_ctree_expand_to_depth): expand tree to specified depth
+       (gtk_ctree_collapse_to_depth): collapse all nodes with level >= depth
+
 Sun Jul 19 23:51:05 1998  Lars Hamann  <lars@gtk.org>
 
        * gtk/gtkclist.c (scroll_vertical): fix for vertical scrolling in case
index 17f23e8967a787ae014b0d522bc9c05998b40216..759f84500473d654fe71d2d38cfeac1dd0793f34 100644 (file)
@@ -125,6 +125,9 @@ static void tree_expand                 (GtkCTree      *ctree,
 static void tree_collapse               (GtkCTree      *ctree, 
                                         GList         *node,
                                         gpointer       data);
+static void tree_collapse_to_depth      (GtkCTree      *ctree, 
+                                        GList         *node, 
+                                        gint           depth);
 static void tree_toggle_expansion       (GtkCTree      *ctree,
                                         GList         *node,
                                         gpointer       data);
@@ -3225,6 +3228,15 @@ tree_collapse (GtkCTree *ctree,
                     data);
 }
 
+static void
+tree_collapse_to_depth (GtkCTree *ctree, 
+                       GList    *node, 
+                       gint      depth)
+{
+  if (node && GTK_CTREE_ROW (node)->level == depth)
+    gtk_ctree_collapse_recursive (ctree, node);
+}
+
 static void
 tree_toggle_expansion (GtkCTree *ctree,
                       GList    *node,
@@ -3883,6 +3895,9 @@ gtk_ctree_post_recursive (GtkCTree     *ctree,
   GList *work;
   GList *tmp;
 
+  g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
+
   if (node)
     work = GTK_CTREE_ROW (node)->children;
   else
@@ -3899,6 +3914,44 @@ gtk_ctree_post_recursive (GtkCTree     *ctree,
     func (ctree, node, data);
 }
 
+void
+gtk_ctree_post_recursive_to_depth (GtkCTree     *ctree, 
+                                  GList        *node,
+                                  gint          depth,
+                                  GtkCTreeFunc  func,
+                                  gpointer      data)
+{
+  GList *work;
+  GList *tmp;
+
+  g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
+
+  if (depth < 0)
+    {
+      gtk_ctree_post_recursive (ctree, node, func, data);
+      return;
+    }
+
+  if (node)
+    work = GTK_CTREE_ROW (node)->children;
+  else
+    work = GTK_CLIST (ctree)->row_list;
+
+  if (work && GTK_CTREE_ROW (work)->level <= depth)
+    {
+      while (work)
+       {
+         tmp = GTK_CTREE_ROW (work)->sibling;
+         gtk_ctree_post_recursive_to_depth (ctree, work, depth, func, data);
+         work = tmp;
+       }
+    }
+
+  if (node && GTK_CTREE_ROW (node)->level <= depth)
+    func (ctree, node, data);
+}
+
 void
 gtk_ctree_pre_recursive (GtkCTree     *ctree, 
                         GList        *node,
@@ -3908,6 +3961,8 @@ gtk_ctree_pre_recursive (GtkCTree     *ctree,
   GList *work;
   GList *tmp;
 
+  g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
 
   if (node)
     {
@@ -3925,6 +3980,45 @@ gtk_ctree_pre_recursive (GtkCTree     *ctree,
     }
 }
 
+void
+gtk_ctree_pre_recursive_to_depth (GtkCTree     *ctree, 
+                                 GList        *node,
+                                 gint          depth, 
+                                 GtkCTreeFunc  func,
+                                 gpointer      data)
+{
+  GList *work;
+  GList *tmp;
+
+  g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
+
+  if (depth < 0)
+    {
+      gtk_ctree_pre_recursive (ctree, node, func, data);
+      return;
+    }
+
+  if (node)
+    {
+      work = GTK_CTREE_ROW (node)->children;
+      if (GTK_CTREE_ROW (node)->level <= depth)
+       func (ctree, node, data);
+    }
+  else
+    work = GTK_CLIST (ctree)->row_list;
+
+  if (work && GTK_CTREE_ROW (work)->level <= depth)
+    {
+      while (work)
+       {
+         tmp = GTK_CTREE_ROW (work)->sibling;
+         gtk_ctree_pre_recursive_to_depth (ctree, work, depth, func, data);
+         work = tmp;
+       }
+    }
+}
+
 gboolean
 gtk_ctree_is_visible (GtkCTree *ctree, 
                      GList    *node)
@@ -4085,6 +4179,7 @@ gtk_ctree_expand_recursive (GtkCTree *ctree,
   gboolean thaw = FALSE;
 
   g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
 
   clist = GTK_CLIST (ctree);
 
@@ -4104,6 +4199,36 @@ gtk_ctree_expand_recursive (GtkCTree *ctree,
     gtk_clist_thaw (clist);
 }
 
+void 
+gtk_ctree_expand_to_depth (GtkCTree *ctree,
+                          GList    *node,
+                          gint      depth)
+{
+  GtkCList *clist;
+  gboolean thaw = FALSE;
+
+  g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
+
+  clist = GTK_CLIST (ctree);
+
+  if (node && GTK_CTREE_ROW (node)->is_leaf)
+    return;
+
+  if (((node && gtk_ctree_is_visible (ctree, node)) || !node) && 
+      !GTK_CLIST_FROZEN (clist))
+    {
+      gtk_clist_freeze (clist);
+      thaw = TRUE;
+    }
+
+  gtk_ctree_post_recursive_to_depth (ctree, node, depth,
+                                    GTK_CTREE_FUNC (tree_expand), NULL);
+
+  if (thaw)
+    gtk_clist_thaw (clist);
+}
+
 void
 gtk_ctree_collapse (GtkCTree *ctree,
                    GList    *node)
@@ -4125,6 +4250,7 @@ gtk_ctree_collapse_recursive (GtkCTree *ctree,
   gboolean thaw = FALSE;
 
   g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
 
   if (node && GTK_CTREE_ROW (node)->is_leaf)
     return;
@@ -4144,6 +4270,37 @@ gtk_ctree_collapse_recursive (GtkCTree *ctree,
     gtk_clist_thaw (clist);
 }
 
+void 
+gtk_ctree_collapse_to_depth (GtkCTree *ctree,
+                            GList    *node,
+                            gint      depth)
+{
+  GtkCList *clist;
+  gboolean thaw = FALSE;
+
+  g_return_if_fail (ctree != NULL);
+  g_return_if_fail (GTK_IS_CTREE (ctree));
+
+  if (node && GTK_CTREE_ROW (node)->is_leaf)
+    return;
+
+  clist = GTK_CLIST (ctree);
+
+  if (((node && gtk_ctree_is_visible (ctree, node)) || !node) && 
+      !GTK_CLIST_FROZEN (clist))
+    {
+      gtk_clist_freeze (clist);
+      thaw = TRUE;
+    }
+
+  gtk_ctree_post_recursive_to_depth (ctree, node, depth,
+                                    GTK_CTREE_FUNC (tree_collapse_to_depth),
+                                    GINT_TO_POINTER (depth));
+
+  if (thaw)
+    gtk_clist_thaw (clist);
+}
+
 void
 gtk_ctree_toggle_expansion (GtkCTree *ctree,
                            GList    *node)
index 58f2edab4671491a9fe980aee500e1a842b5dbfc..cd6153c7af42fb1e657143d76dc69dbbe24f91c6 100644 (file)
@@ -181,32 +181,42 @@ void       gtk_ctree_remove                 (GtkCTree     *ctree,
  *  information                                            *
  ***********************************************************/
 
-void       gtk_ctree_post_recursive         (GtkCTree     *ctree, 
-                                            GList        *node,
-                                            GtkCTreeFunc  func,
-                                            gpointer      data);
-void       gtk_ctree_pre_recursive          (GtkCTree     *ctree, 
-                                            GList        *node,
-                                            GtkCTreeFunc  func,
-                                            gpointer      data);
-gboolean   gtk_ctree_is_visible             (GtkCTree     *ctree, 
-                                            GList        *node);
-GList *    gtk_ctree_last                   (GtkCTree     *ctree,
-                                            GList        *node);
-GList *    gtk_ctree_find_glist_ptr         (GtkCTree     *ctree,
-                                            GtkCTreeRow  *ctree_row);
-gint       gtk_ctree_find                   (GtkCTree     *ctree,
-                                            GList        *node,
-                                            GList        *child);
-gboolean   gtk_ctree_is_ancestor            (GtkCTree     *ctree,
-                                            GList        *node,
-                                            GList        *child);
-GList *    gtk_ctree_find_by_row_data       (GtkCTree     *ctree,
-                                            GList        *node,
-                                            gpointer      data);
-gboolean   gtk_ctree_is_hot_spot            (GtkCTree     *ctree,
-                                            gint          x,
-                                            gint          y);
+void       gtk_ctree_post_recursive          (GtkCTree     *ctree, 
+                                             GList        *node,
+                                             GtkCTreeFunc  func,
+                                             gpointer      data);
+void       gtk_ctree_post_recursive_to_depth (GtkCTree     *ctree, 
+                                             GList        *node,
+                                             gint          depth,
+                                             GtkCTreeFunc  func,
+                                             gpointer      data);
+void       gtk_ctree_pre_recursive           (GtkCTree     *ctree, 
+                                             GList        *node,
+                                             GtkCTreeFunc  func,
+                                             gpointer      data);
+void       gtk_ctree_pre_recursive_to_depth  (GtkCTree     *ctree, 
+                                             GList        *node,
+                                             gint          depth,
+                                             GtkCTreeFunc  func,
+                                             gpointer      data);
+gboolean   gtk_ctree_is_visible              (GtkCTree     *ctree, 
+                                             GList        *node);
+GList *    gtk_ctree_last                    (GtkCTree     *ctree,
+                                             GList        *node);
+GList *    gtk_ctree_find_glist_ptr          (GtkCTree     *ctree,
+                                             GtkCTreeRow  *ctree_row);
+gint       gtk_ctree_find                    (GtkCTree     *ctree,
+                                             GList        *node,
+                                             GList        *child);
+gboolean   gtk_ctree_is_ancestor             (GtkCTree     *ctree,
+                                             GList        *node,
+                                             GList        *child);
+GList *    gtk_ctree_find_by_row_data        (GtkCTree     *ctree,
+                                             GList        *node,
+                                             gpointer      data);
+gboolean   gtk_ctree_is_hot_spot             (GtkCTree     *ctree,
+                                             gint          x,
+                                             gint          y);
 
 /***********************************************************
  *   Tree signals : move, expand, collapse, (un)select     *
@@ -220,10 +230,16 @@ void       gtk_ctree_expand                 (GtkCTree     *ctree,
                                             GList        *node);
 void       gtk_ctree_expand_recursive       (GtkCTree     *ctree,
                                             GList        *node);
+void       gtk_ctree_expand_to_depth        (GtkCTree     *ctree,
+                                            GList        *node,
+                                            gint          depth);
 void       gtk_ctree_collapse               (GtkCTree     *ctree,
                                             GList        *node);
 void       gtk_ctree_collapse_recursive     (GtkCTree     *ctree,
                                             GList        *node);
+void       gtk_ctree_collapse_to_depth      (GtkCTree     *ctree,
+                                            GList        *node,
+                                            gint          depth);
 void       gtk_ctree_toggle_expansion       (GtkCTree     *ctree,
                                             GList        *node);
 void       gtk_ctree_toggle_expansion_recursive (GtkCTree *ctree,